#include<bits/stdc++.h>
using namespace std;

struct node {
    int x, y, dist;
    bool operator < (const node &x) const {
        return dist > x.dist;
    }
};

int dist[105][105];
int a[105][105];
pair<int, int> pos[10005];
bool vis[105][105];

int n, m, k;
int zx, zy;

int dx[] = { -1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};

//int transAxis(int x, int y) {
//    return (x - 1) * m + y;
//}

void dijkstra() {
    memset(dist, 0x3f, sizeof dist);
    dist[zx][zy] = 0;

    priority_queue<node> q;
    q.push({zx, zy, 0});

    while(!q.empty()) {
        node t = q.top();
        q.pop();

        if (vis[t.x][t.y]) continue;
        vis[t.x][t.y] = 1;

        for(int i = 0; i < 4; i++) {
            int xx = t.x + dx[i];
            int yy = t.y + dy[i];

            if(xx < 1 || xx > n || yy < 1 || yy > m || !a[xx][yy])
                continue;

            if(dist[xx][yy] > t.dist + 1) {
                dist[xx][yy] = t.dist + 1;
                q.push({xx, yy, dist[xx][yy]});
            }
        }
    }
}
vector<int> cnt[10005];

void fun() {
    dijkstra();


    for(int i = 1; i <= k; i++) {
        if(dist[pos[i].first][pos[i].second] != 0x3f3f3f3f)
            cnt[dist[pos[i].first][pos[i].second]].push_back(i);
    }

    int mn = INT_MAX, idx = 0;
    bool flag = 0;

    for(int i = 1; i <= n * m; i++) {
        if(cnt[i].size() == 1) {
            mn = i;
            idx = cnt[i][0];
            flag = 1;
            break;
        }
    }

    if(!flag)
        cout << "No winner.";
    else
        cout << idx << " " << mn;
}

signed main() {
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cin >> a[i][j];
            if(a[i][j] == 2) {
                zx = i;
                zy = j;
            }
        }
    }
    cin >> k;
    for(int i = 1; i <= k; i++)
        cin >> pos[i].second >> pos[i].first;

    fun();
    return 0;
}

